/**
 * ...
 * >author		João Vítor de Souza
 */

package com.cupcakeengine.utils 
{
	import flash.geom.Point;

	public class MathUtil 
	{
		// ___________________________________________________________________ CONSTANTS
		
		public static const RADIANS								: Number = Math.PI / 180;
		public static const DEGREES								: Number = 180 / Math.PI;
		
		// ___________________________________________________________________ CLASS PROPERTIES
		
		// ___________________________________________________________________ INSTANCE PROPERTIES
		
		// ___________________________________________________________________ GETTERS AND SETTERS
		
		// ___________________________________________________________________ CONSTRUCTOR
		
		// ___________________________________________________________________ PUBLIC METHODS
		
		static public function d2r(angle:Number):Number
		{
			return angle * RADIANS;
		}
		
		static public function r2d(angle:Number):Number
		{
			return angle * DEGREES;
		}
		
		static public function abs(value:Number):Number
		{			
			return (value ^ (value >> 31)) - (value >> 31);
		}
		
		static public function getAngleBetweenPoints(p1:Point, p2:Point):Number
		{
			var dx:Number = p1.x - p2.x;
			var dy:Number = p1.y - p2.y;
			
			return Math.atan2(dy, dx);
		}

		static public function getDistanceBetweenPoints(p1:Point, p2:Point):Number
		{
			var dx:Number = p1.x - p2.x;
			var dy:Number = p1.y - p2.y;			

			return Math.sqrt(dx * dx + dy * dy);
		}
		
		// ___________________________________________________________________ PRIVATE METHODS
		
		// ___________________________________________________________________ EVENTS
	}
}

